package sbeam.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import sbeam.mapper.EvaluateMapper;
import sbeam.model.Evaluate;
import sbeam.service.EvaluateService;
@Service
public class EvaluateServiceImpl implements EvaluateService {
	
	@Autowired
	private EvaluateMapper dao;
	
	@Override
	public void addComment(Evaluate eva,Integer uid) {
		if(eva.getEvaPId()!=null) {
			this.dao.addPalyComment(eva,uid);
		}else {
			this.dao.addSalesComment(eva,uid);
		}
	}

	@Override
	public List<Evaluate> findEvaluateByPalyGame(Integer gid) {
		return this.dao.findEvaluateByPalyGame(gid);
	}

	@Override
	public Evaluate findEvaluateByUserId(Integer uid,Integer gid) {
		return this.dao.findEvaluateByUserId(uid, gid);
	}

	@Override
	public void updateComment(Evaluate e) {
		this.dao.updateComment(e);
		
	}

	@Override
	public boolean isEvaluate(Integer userId, Integer evaPId) {
		if((this.dao.findEvaluate(userId, evaPId))==null) {
			return false;
		}
		return true;
	}

}
